#include	<stdio.h>
#include    <stdlib.h>
#include	<fcntl.h>

main()
{
	int	fd ;
	int	newfd;
	char	line[100];

	fgets( line, 100, stdin ); printf("%s", line );//从键盘上读取输出的字符串
	fgets( line, 100, stdin ); printf("%s", line );
	fgets( line, 100, stdin ); printf("%s", line );

	fd = open("data", O_RDONLY); //以只读方式打开文件

	newfd = dup2(fd,0);	
	
	if ( newfd != 0 ){
		fprintf(stderr,"Could not duplicate fd to 0\n");
		exit(1);
	}
	close(fd);			

	fgets( line, 100, stdin ); printf("%s", line );//从文件中读取输出字符串
	fgets( line, 100, stdin ); printf("%s", line );
	fgets( line, 100, stdin ); printf("%s", line );
}

